<!doctype html>
<html>
<head>
<meta charset="utf-8">

<title>canvas的变换</title>
<style>
body {background:black; text-align:center;}
#c1 {background:white;}
</style>
<script>
//角度->弧度
function d2a(n)
{
	return n*Math.PI/180;
}

window.onload=function ()
{
	var oC=document.getElementById('c1');
	var gd=oC.getContext('2d');
	
        // canvas的旋转——参考点按照画布的左上角旋转
        //rotate必须在画图之前。因为图形一旦绘制完毕，任何操作都改变不了
	gd.rotate(d2a(30));
       
        //位移  
        //gd.translate(100,200);
	gd.strokeRect(100, 100, 200, 150);
	
       //填充颜色
	gd.fillStyle='rgba(255,0,0,0.3)';
	// gd.fillRect(0,0,oC.width,oC.height);
	
};
</script>
</head>

<body>
<canvas id="c1" width="800" height="600"></canvas>
</body>
</html>





